home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Util / B / Benchmark folder / Source Files / TBenchMarkView.cp < prev    next >
Encoding:
Text File  |  1993-04-20  |  4.3 KB  |  151 lines  |  [TEXT/MPS ]

  1. // Copyright © 1992-1993 Emergent Behavior. All rights reserved.
  2.  
  3. //=================================================================
  4. #ifndef _TBENCHMARKVIEW_
  5.     #include "TBenchMarkView.h"
  6. #endif
  7.  
  8. #ifndef _TBENCHMARKDOCUMENT_
  9.     #include "TBenchMarkDocument.h"
  10. #endif
  11.  
  12. //=================================================================
  13. TBenchMarkView::TBenchMarkView(Point size, TDocument* theDoc)
  14.     : TBufferedView(size, theDoc)
  15. {    
  16.  
  17.  
  18. }
  19.  
  20. //-----------------------------------------------------------------
  21. TBenchMarkView::~TBenchMarkView()
  22. {
  23. }
  24.  
  25. //-----------------------------------------------------------------
  26. void
  27. TBenchMarkView::DisplayWaitPict()
  28. {
  29.     const Point kCorner = {80,80};
  30.     short kWaitPictID;
  31.     if ( TComputer::HasColorQuickDraw() )     //  if the computer doesn't have color QuickDraw then 
  32.         kWaitPictID = 1002;                    //    we will use a black and white pict
  33.     else
  34.         kWaitPictID = 1004;
  35.     TPicture picture( kWaitPictID, kCorner, this);
  36.     fItemList.AdoptItem( &picture );
  37.     this->InvalidateAll();
  38.     this->DrawContents();
  39. }
  40. //-----------------------------------------------------------------
  41. void
  42. TBenchMarkView::Draw()
  43. {
  44.     const short kNumDigits = 2;
  45.     TBenchMarkDocument* theDoc = this->GetBenchMarkDocument();
  46.     PenNormal();
  47.     if ( theDoc->HardwareTested() )
  48.         this->SetHardwareDisplay();
  49.     else
  50.         this->UninitializedHardwareDisplay();
  51.     fAdditionTimeText->SetText( theDoc->GetAdditionSpeed()/ (extended)kTicksInSecond, kNumDigits );
  52.     fDivisionTimeText->SetText( theDoc->GetDivisionSpeed()/ (extended)kTicksInSecond, kNumDigits );
  53.     fRandomNumberTimeText->SetText( theDoc->GetRandomNumberSpeed()/ (extended)kTicksInSecond, kNumDigits );
  54.     fCompositeScoreText->SetText( (extended)theDoc->GetCompositeScore(), kNumDigits );
  55. }
  56.  
  57.  
  58. //-----------------------------------------------------------------
  59. void
  60. TBenchMarkView::DoMakeItems()
  61. {
  62.     const short spacing = 25;
  63.     const Point kOrigin ={0,0};
  64.     short kBkgdResID;
  65.     if ( TComputer::HasColorQuickDraw() )     // if the computer doesn't have color QuickDraw then 
  66.         kBkgdResID = 1001;                    //    we will use a black and white pict
  67.     else
  68.         kBkgdResID = 1003;
  69.     fItemList.AdoptItem( new TPicture( kBkgdResID, kOrigin, this) );
  70.     Rect textRect = { 55,205, 75, 260 };
  71.     
  72.     fHasMathChipText = new TText( textRect, this);
  73.     fItemList.AdoptItem( fHasMathChipText );
  74.  
  75.     textRect.top += spacing;
  76.     textRect.bottom += spacing;
  77.     fHas32BitQDText = new TText( textRect, this);
  78.     fItemList.AdoptItem( fHas32BitQDText );
  79.  
  80.     textRect.top += spacing;
  81.     textRect.bottom += spacing;
  82.     fUsingSystem7Text = new TText( textRect, this);
  83.     fItemList.AdoptItem( fUsingSystem7Text );
  84.  
  85.     textRect.top += spacing;
  86.     textRect.bottom += spacing;
  87.     fHasColorQDText = new TText( textRect, this);
  88.     fItemList.AdoptItem( fHasColorQDText );
  89.     
  90.     Rect textRect2 = { 180,185, 200, 230 };
  91.     fAdditionTimeText = new TText( textRect2, this);
  92.     fItemList.AdoptItem( fAdditionTimeText );
  93.  
  94.     textRect2.top += spacing;
  95.     textRect2.bottom += spacing;
  96.     fDivisionTimeText = new TText( textRect2, this);
  97.     fItemList.AdoptItem( fDivisionTimeText );
  98.     
  99.     textRect2.top += spacing;
  100.     textRect2.bottom += spacing;
  101.     fRandomNumberTimeText = new TText( textRect2, this);
  102.     fItemList.AdoptItem( fRandomNumberTimeText );
  103.     
  104.     textRect2.top += spacing;
  105.     textRect2.bottom += spacing;
  106.     fCompositeScoreText = new TText( textRect2, this);
  107.     fItemList.AdoptItem( fCompositeScoreText );
  108.  
  109. }
  110.  
  111. //-----------------------------------------------------------------
  112. void
  113. TBenchMarkView::SetHardwareDisplay()
  114. {
  115.     if ( this->GetBenchMarkDocument()->HasMathChip() )
  116.         fHasMathChipText->SetText( "\pYes" );
  117.     else
  118.         fHasMathChipText->SetText( "\pNo" );
  119.         
  120.     if ( this->GetBenchMarkDocument()->Has32BitQD() )
  121.         fHas32BitQDText->SetText( "\pYes" );
  122.     else
  123.         fHas32BitQDText->SetText( "\pNo" );
  124.  
  125.     if ( this->GetBenchMarkDocument()->UsingSystem7() )
  126.         fUsingSystem7Text->SetText( "\pYes" );
  127.     else
  128.         fUsingSystem7Text->SetText( "\pNo" );
  129.  
  130.     if ( this->GetBenchMarkDocument()->HasColorQD() )
  131.         fHasColorQDText->SetText( "\pYes" );
  132.     else
  133.         fHasColorQDText->SetText( "\pNo" );
  134. }
  135.  
  136. //-----------------------------------------------------------------
  137. void
  138. TBenchMarkView::UninitializedHardwareDisplay()
  139. {
  140.     fHasMathChipText->SetText( "\p???" );
  141.     fHas32BitQDText->SetText( "\p???" );
  142.     fUsingSystem7Text->SetText( "\p???" );
  143.     fHasColorQDText->SetText( "\p???" );
  144. }
  145.  
  146. //-----------------------------------------------------------------
  147. TBenchMarkDocument*
  148. TBenchMarkView::GetBenchMarkDocument()
  149. {
  150.     return (TBenchMarkDocument*)fDocument;
  151. }